﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UnitTest
{
    public class TestTask
    {
        public async Task Test1()
        {
            Task task = new Task(() =>
            {
                Console.WriteLine("开始"+ DateTime.Now);
                Thread.Sleep(5 * 1000);
                Console.WriteLine("结束"+DateTime.Now);
            });
           task.Start();
        }

        public async Task Test2()
        {
            Task task = new Task(() =>
            {
                Console.WriteLine("await开始" + DateTime.Now);
                Thread.Sleep(5 * 1000);
                int a = 0;
                int ddd = 6 / a;
                Console.WriteLine("await结束" + DateTime.Now);
            });
            task.Start();
            await task;
        }
    }
}
